﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T15_OOP2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Product product = new Product();//错误：抽象类不能实例化
                Book book = new Book();//默认或无参构造函数能正确初始化，无需显式调用
                book.Name = "天龙八部";
                book.Price = 88.0M;
                book.Isbn = "5863452159651";
                book.Intro = "金庸-江湖";
                book.Show();
                book.ShowDetail();
                //book = null;//谨慎使用，可提高内容使用的效率
                Console.WriteLine("===============");
                Digital digital = new Digital();
                digital.Name = "蓝牙耳机";
                digital.Price = 56M;
                digital.Barcode = "125421";
                Action buy = new Action();
                buy.Buy(book);
                buy.Buy(digital);
                buy.Show();
            }
            catch(ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("输入信息有误!");
            }
            catch (Exception)
            {
                Console.WriteLine("其他错误");
            }
            //内存垃圾回收
            System.GC.Collect();
            Console.ReadKey();

        }
    }
}
